package StudyCode.summary.Basic.numberformat;

import java.text.NumberFormat;
import java.util.Locale;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class DefaultFormats {
	public static void main(String[] args) {
		double value = 1234567.895;
		// Default locale
		printFormatted(Locale.getDefault(), value);
		// US locale
		Locale indianLocale = new Locale("en", "US");
		printFormatted(indianLocale, value);
	}

	private static void printFormatted(Locale locale, double value) {
		NumberFormat nf = NumberFormat.getInstance(locale);
		NumberFormat cf = NumberFormat.getCurrencyInstance(locale);

		System.out.println("要格式化的值: " + value + " 国家或地区: " + locale);
		System.out.println("默认格式化后的值: " + nf.format(value));
		System.out.println("货币单位格式化的值: " + cf.format(value));
		System.out.println();
	}
}
